package edu.hcnu.controller;

import edu.hcnu.po.SheBei;
import edu.hcnu.service.SheBeiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@RestController
@RequestMapping("/shebei")
public class SheBeiController {

    @Autowired
    private SheBeiService service;

    @GetMapping("list")
    public ModelAndView list(){
        List<SheBei> list =service.list();
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("list",list);
        modelAndView.setViewName("table");
        return modelAndView;
    }

    @GetMapping("delete/{id}")
    public ModelAndView delete(@PathVariable("id") String id){
        if(service.deleteByID(id)){
          return   this.list();
        }
        return null;
    }



}
